package com.maybach.common.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zhaoshuai on 16/1/14.
 */
public abstract class BaseConstants {

    public static final int DEFAULT_PAGE_PER_COUNT = 10; //默认每页10条数据

    private static final Map<Integer, String> MESSAGES = new HashMap<>();

    static {
        MESSAGES.put(ResultCode.SUCCESS, "成功");
        MESSAGES.put(ResultCode.NO_DATA, "无数据");
        MESSAGES.put(ResultCode.PARAM_ERROR, "参数错误");
        MESSAGES.put(ResultCode.INSERT_FAIL, "插入数据错误");
        MESSAGES.put(ResultCode.QUERY_FAIL, "查询错误");
        MESSAGES.put(ResultCode.UPDATE_FAIL, "修改数据错误");
        MESSAGES.put(ResultCode.EXCEPTION, "系统异常");
        MESSAGES.put(ResultCode.DATA_ERROR, "数据异常");
        MESSAGES.put(ResultCode.DUPLICATE_ERROR, "重复操作");
        MESSAGES.put(ResultCode.NO_AUTH, "没有权限,请联系@婷姐进行授权");

    }

    public static String getMessage(int code) {
        if (MESSAGES.containsKey(code)) {
            return MESSAGES.get(code);
        }
        return "";
    }

    public final class ResultCode {
        public static final int SUCCESS = 1001;
        public static final int NO_DATA = 1002;
        public static final int PARAM_ERROR = 1003;
        public static final int EXCEPTION = 1004;
        public static final int INSERT_FAIL = 1005;
        public static final int QUERY_FAIL = 1006;
        public static final int UPDATE_FAIL = 1007;
        public static final int DATA_ERROR = 1008;

        public static final int DUPLICATE_ERROR = 1009;
        public static final int NO_AUTH = 1010;

    }

}
